package com.kkd.kkdapp.activity;

import com.kkd.kkdapp.Environment;
import com.kkd.kkdapp.R;
import com.kkd.kkdapp.utils.PreferenceUtils;

import android.content.Intent;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;

public class SplashWebActivity extends KKDWebActivity {

	@Override
	public boolean onKey(View v, int keyCode, KeyEvent event) {
		if (event.getAction() == KeyEvent.ACTION_DOWN) {
			switch (v.getId()) {
			case R.id.treaty_web:
				if (keyCode == KeyEvent.KEYCODE_BACK) {

					if (mWebView.canGoBack()) {
						mWebView.goBack();
					} else {

						Intent intent = new Intent(SplashWebActivity.this,
								HomeActivity.class);
						intent.putExtra("toActivity", 0);
						intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
						startActivity(intent);
						finish();
					}

					return true;
				}
				break;
			}
		}

		return false;
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
		case R.id.treat_top_img: // 后退
			if (isBBS) {
				Intent intent = new Intent(SplashWebActivity.this,
						HomeActivity.class);
				intent.putExtra("toActivity", 0);
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
				finish();
			} else {
				if (mWebView.canGoBack()) {
					mWebView.goBack();
				} else {
					Intent intent = new Intent(SplashWebActivity.this,
							HomeActivity.class);
					intent.putExtra("toActivity", 0);
					intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
					startActivity(intent);
					finish();
				}
			}

			break;

		}
	}
}
